<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    
    <!-- This office.js library holds the JavaScript API for Office. -->
    <script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" type="text/javascript"></script>
    
    <!-- The following two files hold the Office UI Fabric styles and components. -->
	<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.min.css" />
	<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.components.min.css" />
    <script src="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/js/fabric.min.js"></script>
    
    <script src="../../new_common/cac.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../onedrive_common/ac.js"></script>
</head>

<body>
	<div id="infoMsg" class="ms-MessageBar" style="display: none">
	  <div class="ms-MessageBar-content">
	    <div class="ms-MessageBar-icon">
	      <img class="busyImg" src="/images/spin.gif" style="display: none">
	      <i class="ms-Icon ms-Icon--Info"></i>
	    </div>
	    <div class="ms-MessageBar-text" style="font-size: 14px">
	    </div>
	  </div>
	</div>
	<div id="errorMsg" class="ms-MessageBar ms-MessageBar--error" style="display: none">
	  <div class="ms-MessageBar-content">
	    <div class="ms-MessageBar-icon">
	      <img class="busyImg" src="/images/spin.gif" style="display: none">
	      <i class="ms-Icon ms-Icon--ErrorBadge"></i>
	    </div>
	    <div class="ms-MessageBar-text" style="font-size: 14px">
	    </div>
	  </div>
	</div>
	<div id="successMsg" class="ms-MessageBar ms-MessageBar--success" style="display: none">
	  <div class="ms-MessageBar-content">
	    <div class="ms-MessageBar-icon">
	      <img class="busyImg" src="/images/spin.gif" style="display: none">
	      <i class="ms-Icon ms-Icon--Completed"></i>
	    </div>
	    <div class="ms-MessageBar-text" style="font-size: 14px">
	    </div>
	  </div>
	</div>
	<div id="openLink" style="display: none;width: 100%;text-align: center;"></div>
	<div style="width:100%;text-align: center;position: fixed;bottom: 0px;height: 50px;margin-left: -8px;" id="okBtn">
		<button class="ms-Button ms-Button--primary">
		  <span class="ms-Button-label">OK</span> 
		</button>
	</div>
	
	<script type="text/javascript">
		var msgTypeId = '#infoMsg';
	
		function updateUI(msg, openLinkId, isError, isInfo, isSuccess, showBusy)
		{
			var msgs = AC.$$('.ms-MessageBar-text');
			
			for (var i = 0; i < msgs.length; i++)
			{
				msgs[i].innerHTML = AC.htmlEntities(msg);
			}
			
			AC.$(msgTypeId).style.display = 'none';
			msgTypeId = '#infoMsg';
			
			if (isError) msgTypeId = '#errorMsg';
			else if (isSuccess) msgTypeId = '#successMsg';			
			
			AC.$(msgTypeId).style.display = 'block';
			AC.$('#okBtn').style.display = isInfo? 'none' : 'block';
			
			var busyImgs = AC.$$('.busyImg');
			
			for (var i = 0; i < busyImgs.length; i++)
			{
				busyImgs[i].style.display = showBusy? '' : 'none';
			}
			
			if (openLinkId != null)
			{
				var openLink = AC.$('#openLink');
				openLink.style.display = 'block';
				openLink.innerHTML = '<a href="https://' + window.location.hostname + '/?open=' + openLinkId + '" target="_blank"><img src=/images/edit32.png></a>';
			}
		};
		
		var msg = AC.getUrlParam('msg', true);
		var isError = AC.getUrlParam('error') == '1';
		var isInfo = AC.getUrlParam('info') == '1';
		var isSuccess = AC.getUrlParam('success') == '1';
		var showBusy =  AC.getUrlParam('busy') == '1';
		var openLinkId = AC.getUrlParam('openLinkId');

		updateUI(msg, openLinkId, isError, isInfo, isSuccess, showBusy);
		
		Office.initialize = function () 
		{
			new fabric['Button'](AC.$('#okBtn'), function() 
			{
				Office.context.ui.messageParent('closeMe');	
		    });
		};
	</script>
</body>

</html>